package gov.pbc.nn.kjgl.software.view;

import gov.pbc.nn.kjgl.entity.ProjectFile;
import gov.pbc.nn.kjgl.software.dao.YwDeptChangeDao;

import java.util.List;
import java.util.Map;

import org.quartz.ExecuteInJTATransaction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.bstek.dorado.annotation.DataProvider;
import com.bstek.dorado.annotation.Expose;

@Component("ywDeptChangePR")
public class YwDeptChangePR {

	@Autowired
	private YwDeptChangeDao ywDeptChangeDao;

	@Expose
	public int getState(String processInstanceId) {
		return ywDeptChangeDao.getState(processInstanceId);
	}

	/**
	 * 获取业务干系科长审核的相关数据
	 * 
	 * @param id
	 * @return
	 */
	@DataProvider
	public Map<String, Object> loadProjectByChange(String id) {
		return ywDeptChangeDao.loadProjectByChange(id);
	}

	/**
	 * 业务干系科长是否同意变更
	 * 
	 * @param taskId
	 * @param changeId
	 * @param opinionText
	 * @param i
	 * @param type
	 * 
	 * 
	 */
	@Transactional
	@Expose
	public void agreeYwgxkz(String taskId, String changeId, String opinionText,
			int i, int type) {
		ywDeptChangeDao.agreeYwgxkz(taskId, changeId, opinionText, i, type);
	}

	/**
	 * 根据ProjectChangeId获取相应的附件
	 * 
	 * @param id
	 * @return
	 */
	@DataProvider
	public List<ProjectFile> getProjectFileByChangeId(String id) {
		return ywDeptChangeDao.getProjectFileByChangeId(id);
	}

	/**
	 * 提交项目组成员意见
	 * 
	 * @param taskId
	 * @param opinionText
	 */
	@Transactional
	@Expose
	public void saveShOpinion(String taskId, String opinionText) {
		ywDeptChangeDao.saveShOpinion(taskId, opinionText);
	}

	/**
	 * 根据TaskId获取项目组成员意见
	 * 
	 * @param taskId
	 * @return
	 */
	@DataProvider
	public List<Map<String, Object>> loadXmzOpinion(String taskId) {
		return ywDeptChangeDao.loadXmzOpinion(taskId);
	}

	/**
	 * 管理员和科技处处长审核是否通过变更
	 * 
	 * @param taskId
	 * @param opinionText
	 * @param i
	 */
	@Transactional
	@Expose
	public void GlyAndKjcSh(String taskId, String opinionText, int i) {
		ywDeptChangeDao.GlyAndKjcSh(taskId, opinionText, i);
	}
}
